package com.ruoyi.erp.domain;

import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

@Data
public class ProjectHourReport {
    private Integer holidayConfigId;
    private Date beginDate;
    private Date endDate;
    //应出勤天数
    private BigDecimal needHour;
    private BigDecimal needDays;
    private BigDecimal normalWorkDays;
    private BigDecimal normalWorkHours;
    private BigDecimal freeWorkHours;
    private BigDecimal freeWorkDays;
    private BigDecimal leaveHours;
    private BigDecimal leaveDays;
    private BigDecimal overtimeHours;
    private BigDecimal overtimeDays;
    private BigDecimal maintainWorkHours;
    private BigDecimal maintainWorkDays;
    private int overtimeCount;
    private int leaveCount;
    private int abnormalCount;
    private BigDecimal abnormalHours;
    private BigDecimal abnormalDays;


    public BigDecimal getNeedDays() {
        return needHour == null || needHour.equals(BigDecimal.ZERO) ? BigDecimal.ZERO : needHour.divide(BigDecimal.valueOf(8), 2, BigDecimal.ROUND_HALF_UP);
    }

    public BigDecimal getNormalWorkDays() {
        return normalWorkHours == null || normalWorkHours.equals(BigDecimal.ZERO) ? BigDecimal.ZERO : normalWorkHours.divide(BigDecimal.valueOf(8), 2, BigDecimal.ROUND_HALF_UP);
    }

    public BigDecimal getLeaveDays() {
        return leaveHours == null || leaveHours.equals(BigDecimal.ZERO) ? BigDecimal.ZERO : leaveHours.divide(BigDecimal.valueOf(8), 2, BigDecimal.ROUND_HALF_UP);
    }

    public BigDecimal getOvertimeDays() {
        return overtimeHours == null || overtimeHours.equals(BigDecimal.ZERO) ? BigDecimal.ZERO : overtimeHours.divide(BigDecimal.valueOf(8), 2, BigDecimal.ROUND_HALF_UP);
    }
    public BigDecimal getMaintainWorkDays() {
        return maintainWorkHours == null || maintainWorkHours.equals(BigDecimal.ZERO) ? BigDecimal.ZERO : maintainWorkHours.divide(BigDecimal.valueOf(8), 2, BigDecimal.ROUND_HALF_UP);
    }
    public BigDecimal getFreeWorkDays() {
        return freeWorkHours == null || freeWorkHours.equals(BigDecimal.ZERO) ? BigDecimal.ZERO : freeWorkHours.divide(BigDecimal.valueOf(8), 2, BigDecimal.ROUND_HALF_UP);
    }
    public BigDecimal getAbnormalDays() {
        return abnormalHours == null || abnormalHours.equals(BigDecimal.ZERO) ? BigDecimal.ZERO : abnormalHours.divide(BigDecimal.valueOf(8), 2, BigDecimal.ROUND_HALF_UP);
    }

    public BigDecimal getTotalWorkHours()
    {
        BigDecimal ret = BigDecimal.ZERO;
        if (this.normalWorkHours != null ) {
            ret = ret.add(this.normalWorkHours);
        }
        if (this.freeWorkHours != null ) {
            ret = ret.add(freeWorkHours);
        }
        if (this.maintainWorkHours != null) {
            ret = ret.add(maintainWorkHours);
        }
        return ret;
    }

    /**
     * 获取出席率
     * @return
     */
    public BigDecimal getWorkHourRate()
    {
        if (this.getNeedHour() == null || this.getNeedHour().compareTo(BigDecimal.ZERO) <= 0)
        {
            return BigDecimal.ZERO;
        }
        return getTotalWorkHours().divide(getNeedHour(),2,BigDecimal.ROUND_HALF_UP).multiply(BigDecimal.valueOf(100));
    }
}

